﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SmallBusinessKit.Models.Entities;

namespace SmallBusinessKit.DataAccess.Configurations
{
    public class TestimonialConfig : EntityTypeConfiguration<Testimonial>
    {
        public TestimonialConfig()
        {
            #region Relationships

            #endregion

            #region Properties

            HasKey(p => p.Id);

            Property(p => p.Id)
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(32)
                    .IsRequired();

            Property(p => p.IsVisible)
                    .HasColumnType("bit")
                    .IsRequired();

            Property(p => p.Title)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsRequired();

            Property(p => p.Date)
                    .HasColumnType("datetime2")
                    .IsRequired();

            Property(p => p.Content)            // "Optional" in original, but a testiment with no content doesn't make sense, so it's changed to "Required"
                    .HasColumnType("nvarchar")
                    .HasMaxLength(1024)
                    .IsRequired();

            Property(p => p.Testifier)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsOptional();

            Property(p => p.TestifierTitle)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsOptional();

            Property(p => p.TestifierCompany)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsOptional();

            Property(p => p.ImageUrl)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsOptional();

            Property(p => p.ImageAltText)
                    .HasColumnType("nvarchar")
                    .HasMaxLength(256)
                    .IsOptional();

            // Property(p => p.DisplayOrder)       // defined in original but never used 
            //        .HasColumnType("int")
            //        .IsOptional();

            #endregion
        }
    }
}
